package com.cn.wanxi.servlet;

import com.cn.wanxi.model.UserModel;
import net.sf.json.JSONArray;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/register")
public class Register  extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//       注册，就等于新增一条数据，然后返回新增结果。也要做一个查询，查询用户名是否存在
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        UserModel userModel = new UserModel();
        userModel.setUsername(username);
        userModel.setPassword(password);
        JSONArray jsonArray = JSONArray.fromObject(userModel);

        resp.getWriter().println(jsonArray.toString());
    }
}
